package controllers;

import models.Login;
import models.crawlers.common.ShopCrawler;
import play.data.Form;
import play.mvc.Controller;
import play.mvc.Result;
import views.html.Application.logOn;
import views.html.Application.signUp;
import views.html.index;

public class Application extends Controller {
    private static ShopCrawler crawler;

    public static Result index() {
        return ok(index.render("Project Maria"));
    }
    
    public static Result getLogOn(){
        return ok(logOn.render(form(Login.class)));
    }  
    
    public static Result postLogOn(){
        return TODO;
    }
    
    public static Result getSignUp(){
        return ok(signUp.render(form(Login.class)));
    }
    
    public static Result postSignUp(){
        Form<Login> logOnForm = form(Login.class).bindFromRequest();
        if(logOnForm.hasErrors()) {

            return badRequest(signUp.render(logOnForm));
        } else {
            session("email", logOnForm.get().email);
            return TODO;
        }
    }
}